package tma.sdcbatch11.foodordering;

import java.util.ArrayList;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
import android.widget.AdapterView.OnItemClickListener;

public class DetailStoreActivity extends Activity implements OnClickListener, OnItemClickListener{
	private TypeDishAdapter adapter;

	private ArrayList<View> listText;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_store_detail);

		Intent intent = getIntent();
		ItemKindOfDish item = (ItemKindOfDish) intent.getSerializableExtra("item");

		TextView txtName = (TextView) findViewById(R.id.txt_name);
		TextView txtAddress = (TextView) findViewById(R.id.txt_address);
		Typedish[] list = createList();
		ListView lv = (ListView) findViewById(R.id.listView1);
		adapter = new TypeDishAdapter(this, list);
		lv.setAdapter(adapter);
		

		listText = new ArrayList<View>();
		txtName.setText(item.name);
		txtAddress.setText(item.address);

		listText.add(txtName);
		listText.add(txtAddress);
		
		findViewById(R.id.btn_hide).setOnClickListener(this);
		lv.setOnItemClickListener(this);

	}
	public Typedish[] createList(){
		Typedish[] items = new Typedish[4];
		String[] typedish = getResources().getStringArray(R.array.listtypedish);
			
		for(int i = 0; i < items.length; i++){
				items[i] = new Typedish(typedish[i]);
		}
		return items;
	}
	
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	public void onClick(View v) {
		finish();
		
	}

	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Intent itent = new Intent(getApplicationContext(), List_dish.class);
		startActivity(itent);
		
	}


}
